package com.qcby.byc.demo0422.service.impl;

import com.qcby.byc.demo0422.entity.Depart;
import com.qcby.byc.demo0422.mapper.DepartMapper;
import com.qcby.byc.demo0422.service.DepartService;
import com.qcby.byc.demo0422.service.PersonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @className: PersonServiceImpl
 * @description:
 * @author: lxt
 * @create: 2021-04-22 17:16
 **/

/**
 * REQUIRES_NEW ：创建一个新的事务，如果当前存在事务，则把当前事务挂起。
 */
@Transactional(propagation = Propagation.REQUIRES_NEW)
@Service
public class DepartServiceImpl implements DepartService {

    @Autowired
    private DepartMapper departMapper;

    @Override
    public Depart getById1(Long id) {
        return departMapper.getById1(id);
    }


    @Override
    public void save() {
        Depart depart= new Depart();
        depart.setDepartName("666660430");
        departMapper.save(depart);
    }

    @Override
    public List<Depart> listAllDepartNew(Depart depart) {
        return departMapper.listAllDepartNew(depart);
    }

    @Override
    public List<Depart> listAllDepartAndManager() {
        return departMapper.listAllDepartAndManager();
    }
}
